package com.cloud.base.controller;

import com.cloud.api.constants.MobileVo;
import com.cloud.api.constants.SmsType;
import com.cloud.base.service.ISmsService;
import com.cloud.core.util.R;
import com.cloud.log.annotation.Log;
import com.cloud.log.enums.BusinessType;
import com.cloud.log.enums.OperatorType;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.tags.Tag;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;

import jakarta.annotation.Resource;
import jakarta.validation.Valid;
import java.io.IOException;
import java.time.LocalDateTime;

/**
 * <p>
 * 字典数据表 前端控制器
 * </p>
 *
 * @author dhaigang
 * @since 2023-04-03
 */
@RestController
@Validated
@RequestMapping("/sms")
public class SmsController {
    @Resource
    private ISmsService mySmsService;

    @Tag(name = "v1.0")
    @Operation(summary = "发送验证码")
    @PostMapping("/sendSmsCode")
    @Log(title = "短信管理-发送验证码", businessType = BusinessType.OTHER, operatorType = OperatorType.MANAGE)
    public R sendSmsCode(@RequestBody @Valid MobileVo para, @RequestHeader(value = "clientId",required = true) String clientId) throws IOException {

        mySmsService.sendSmsCode( clientId,para);
        return R.ok();
    }

    @Tag(name = "v1.0")
    @Operation(summary = "控车发送验证码")
    @PostMapping("/sendSmsCodeVehicle")
    @Log(title = "短信管理-控车发送验证码", businessType = BusinessType.OTHER, operatorType = OperatorType.MANAGE)
    public R sendSmsCodeVehicle(@RequestBody @Valid SmsType para) throws IOException {
        mySmsService.sendSmsCodeVehicle(para);
        return R.ok();
    }


}
